
<div class="x_panel">
  <div class="x_content" style="display: block;">
    <!--表格主体内容-->
    <div class="row-fluid">
      <form action="/goods/on.html" method="get">
        <label class="control-label">SPUID</label>
        <input type="text" class="form-control-new" name="form[spuid]" value="{if isset($query.spuid)}{$query.spuid}{/if}">
        <label class="control-label">商品名称</label>
        <input type="text" class="form-control-new" name="form[goods_name]" value="{if isset($query.goods_name)}{$query.goods_name}{/if}">


        <label class="control-label">一级类目</label>
        <select id="first_category" class="form-control-new" name="form[first_category]" >
          <option {if !isset($query.first_category) || $query.first_category=="0"}selected="selected"{/if} value="0">全部</option>
          {foreach $local_search_first_category AS $value1}
          <option {if isset($query.first_category) && $query.first_category==$value1.category_id}selected="selected"{/if} value="{$value1.category_id}">{$value1.category_name}</option>
          {/foreach}
        </select>
        <label class="control-label">二级类目</label>
        <select id="second_category" class="form-control-new" name="form[second_category]" >
          <option {if !isset($query.second_category) || $query.second_category=="0"}selected="selected"{/if} value="0">全部</option>
          {if isset($goods.second_category) && $goods.second_category}
          {foreach $goods.second_category AS $value2}
          <option {if isset($query.second_category) && $query.second_category==$value2.category_id}selected="selected"{/if} value="{$value2.category_id}">{$value2.category_name}</option>
          {/foreach}
          {/if}
        </select>

        <label class="control-label">推荐产品</label>
        <select  class="form-control-new" name="form[ishotornew]" >
          <option {if !isset($query.ishotornew) || $query.ishotornew==0}selected="selected"{/if} value="0">全部</option>
          <option {if isset($query.ishotornew) && $query.ishotornew==1}selected="selected"{/if} value="1">Banner下</option>
          <option {if isset($query.ishotornew) && $query.ishotornew==2}selected="selected"{/if} value="2">底部</option>
        </select>
        <label class="control-label">SKUID</label>
        <input type="text" class="form-control-new" name="form[skuid]" value="{if isset($query.skuid)}{$query.skuid}{/if}">

        <button type="submit" class="btn btn-primary" >查询</button>
      </form>

      <button id="change_price" type="submit" class="btn btn-primary" >自定义批量修改价格</button>

    </div>
    <br>
    <div class="cont">
      <table class="table table-bordered table-striped">
        <thead>
        <tr>
          <th width="100px"></th>
          <th width="100px">SPU ID</th>
          <th width="100px">SKUID</th>
          <th>商品名称</th>
          <th>一级类目</th>
          <th>二级类目</th>
          <th>严选价格</th>
          <th>合约价格</th>
          <th>销售价格</th>
          <!--<th>操作</th>-->
        </tr>
        </thead>
        <tbody>
        {foreach $goodssku.lists as $goodsitem}
        <tr>
          <td><input type="checkbox" name="form[goods_id]" value="{$goodsitem.sku_id}"/></td>
          <td>{$goodsitem.yx_goods_id}</td>
          <td>{$goodsitem.yx_sku_id}</td>
          <td width="200px">{$goodsitem.goods_name}</td>
          <td>
            {if isset($goodsitem.first_category_name)}一级类目:{$goodsitem.first_category_name}{/if}
          </td><td>
            {if isset($goodsitem.second_category_name)}二级类目:{$goodsitem.second_category_name}{/if}
          </td>
          <td>{$goodsitem.yanxuan_price}</td>
          <td>{$goodsitem.channel_price}</td>
          <td>{$goodsitem.sku_price}</td>
          <!--<td>
            <div class="x_content">
              <a class="btn btn-primary btn-xs" href="{eval U(['goods/sku-detail-by-id','id'=>$goodsitem.goods_id])}"> 查看SKU</a>

            </div>
          </td>-->
        </tr>
        {/foreach}
        </tbody>
      </table>
      <!--分页-->
      {Yii::$app->view->render('/com/pager.php',['pager'=>$goodssku.pager])}

    </div>




  </div>
</div>


<div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-hidden="true" id="detail-modal">
  <div class="modal-dialog modal-lg">
    <form action="/goods/change-price.html" method="post">
    <div class="modal-content">
      <div class="modal-header" style="border:none">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span></button>
        <h4 class="modal-title" id="myModalLabel">批量修改价格</h4>
      </div>
      <div class="modal-body">
        <div class="loaders">

          <div class="ball-spin-fade-loader">
            <label class="control-label">批量修改类型</label>
            <input type="radio" name="price_type" value="0">按严选价
            <input type="radio" name="price_type" value="1">自定义

            <label class="control-label">批量修改价格基础</label>
            <input type="radio" name="price_base" value="0">严选价
            <input type="radio" name="price_base" value="1">合约价

            <label class="control-label">批量修改模式</label>
            <input type="radio" name="price_model" value="0">上升
            <input type="radio" name="price_model" value="1">下降

            <label class="control-label">批量修改幅度</label>
            <input type="text" class="form-control-new" name="price_count" value="" placeholder="幅度百分比">
          </div>
        </div>
        <div id="modal-dyn"></div>
      </div>
      <div class="modal-footer" style="border:none;">
        <input name="skuids" type="hidden" id="skuids" value="">
        <button id="go" type="submit" class="copy btn btn-secondary">提交</button>
        <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
      </div>
    </div>
    </form>
  </div>
</div>

<script>
    $('#first_category').change(function (e) {
        var category_id = this.value;
        var url = "{['goods/get-second-category-by-id']|U}";
        $.post(url, 'category_id='+category_id, function (data) {
            $('#second_category').html('');
            $('#second_category').append('<option selected="selected" value="0">全部</option>');
            for(var i=0; i<data.length; i++){
                $('#second_category').append("<option value= '"+data[i].category_id+"'>"+data[i].category_name+"</option>");
            }
        },'json');
    })



    $("#change_price").click(function () {
        var arr = new Array();
        $('input:checkbox').each(function(i) {
            if($(this).is(":checked")) {
                arr[i] =$(this).val();
            }
        });
        var vals = arr.join(",");
        if(vals){
            $('#skuids').val(vals);
            $('#detail-modal').modal('show');
        }else{
            alert("请先选择需要修改的sku");
        }

    })

    /*$("#go").click(function () {
        var skuids = $('#skuids').val();
        var goods_ishotornew = $('#ishotornew').val();
        var goods_sort = $('#goods-sort').val();
        var url = "{['goods/recommend']|U}";
        $.post(url, 'goods_id='+goods_id+'&goods_ishotornew='+goods_ishotornew+'&goods_sort='+goods_sort, function (data) {
            window.location.reload();
        },'json');
        $('#detail-modal').modal('hide');
    })*/

</script>
